package com.xlro.servlet;

import com.xlro.domain.User;
import com.xlro.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "SelfInfoServlet",urlPatterns = "/alterSelf")
public class SelfInfoServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String[] attributes = req.getParameterValues("attributes");
        UserService userService = new UserService();

        String title="提示";
        String result = userService.alterInfo(attributes[0], attributes[1], attributes[2], attributes[3], attributes[4], attributes[5],attributes[6]);


        req.getRequestDispatcher("./selfInfo.jsp?title="+title+"&message="+result+"&time=1000").forward(req,resp);
//        req.getRequestDispatcher("./selfInfo.jsp?title="+title+"&message="+ ("男".equals(attributes[6])?"0":"1")+"&time=1000").forward(req,resp);

//        String control = "<script>window.parent.location.reload();</script>";
//        resp.getWriter().println("");


    }
}
